//
//  PFPhotoMaskView.m
//  PrintFamily
//
//  Created by edaihua on 16/3/5.
//  Copyright © 2016年 ___PrintFactory___. All rights reserved.
//

#import "PFPhotoMaskView.h"
#import "PFPhoto.h"
#import "PFPhotoRectManager.h"

@implementation PFPhotoMaskView

- (void)drawRect:(CGRect)rect {
    // Drawing code
    CGContextRef contextRef = UIGraphicsGetCurrentContext();
    CGContextSaveGState(contextRef);
    CGContextSetRGBFillColor(contextRef, 0, 0, 0, 0.5);
    CGContextSetLineWidth(contextRef, 3);
    
    CGRect photoResizeFrame = [self.photo.rectManager.commonRectManager getTargetPhotoRectInResizeView];
    /*
    CGFloat photoResizeHeight = (self.frame.size.width - photoEditerOriginX * 2) * 1.48;
    CGRect photoResizeFrame = CGRectMake(photoEditerOriginX, (self.frame.size.height - photoResizeHeight) / 2, self.frame.size.width - photoEditerOriginX * 2, photoResizeHeight);
    */
    UIBezierPath *photoResizePath = [UIBezierPath bezierPathWithRect:photoResizeFrame];
    UIBezierPath *viewPath = [UIBezierPath bezierPathWithRect:self.frame];
    
    [viewPath appendPath:photoResizePath];
    viewPath.usesEvenOddFillRule = YES;
    [viewPath fill];
    CGContextSetLineWidth(contextRef, 2);
    CGContextSetRGBStrokeColor(contextRef, 255, 255, 255, 1);
    CGFloat dash[2] = {4,4};
    [photoResizePath setLineDash:dash count:2 phase:0];
    [photoResizePath stroke];
    CGContextRestoreGState(contextRef);
    //self.layer.contentsGravity = kCAGravityCenter;
}

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
    return NO;
}


@end
